//
//  main.m
//  08-类的扩展
//
//  Created by 曹曹 on 16/7/13.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Person.h"
#import "CustomizedGenerics.h"
#import "NSMutableArray+Convert.h"
#import "Babysitter.h"

int main(int argc, const char * argv[]) {
//    iOS9新特性三块的深入理解, 创建几个类, 熟悉写法(提交练习成果)
//    iOS 类扩展方式的复习 1> 给NSMutableArray添加convert方法，实现数组倒序。
//    预习UI内容
#pragma mark - Nullability
    Person *per = [[Person alloc] init];
    per.name = @"张三";
    per.age = 30;
    per.gender = @"";
    NSString *perGender = [per gender];
    perGender = nil;
    per.nativePlace = @"锦州";
    NSString *nativePlace = [per nativePlace];
    nativePlace = nil;
#pragma mark - 泛型
    // 带泛型的数组
    NSMutableArray<NSString *> *array = [NSMutableArray arrayWithObjects:@"123", nil];
    NSString *string = @"sss";
    [array addObject:string];
    NSString *last = [array lastObject];
    last = nil;
    // 带泛型的字典
    NSMutableDictionary<NSString *, NSArray *> *diction = [NSMutableDictionary dictionaryWithObjectsAndKeys:@[@1, @2, @3], @"ha", @[], @"he", nil];
    NSLog(@"%@", diction);
    id value = [diction objectForKey:@"ha"].lastObject;
    NSLog(@"%@", value);
    // 自定义泛型
    CustomizedGenerics *one = [[CustomizedGenerics alloc] init];
    CustomizedGenerics<NSArray *> *two = nil;
    CustomizedGenerics<NSMutableArray *> *three = nil;
    one = two;
    one = three;
    two = one;
    three = one;
    //协变性
    two = three;
#pragma mark - kindof
    CustomizedGenerics *four = [[CustomizedGenerics alloc] init];
    NSArray *arrarKindof = [four getArray];
    NSMutableArray *mArrKindof = [four getArray];
#pragma mark - Extension
    Person *person = [[Person alloc] init];
    [person hardworking];
#pragma mark - Category
    NSMutableArray *sourceArray = [NSMutableArray arrayWithObjects:@"abc", @"bcd", @"cde", @"def", @"efg", nil];
    NSArray *convertArray = [sourceArray convertArray];
    NSLog(@"convertArray:%@", convertArray);
#pragma mark - Delegate
    Person *parent = [[Person alloc] init];
    Babysitter *babySitter = [[Babysitter alloc] init];
    parent.delegate = babySitter;
    [parent whenparentsLeave];
    return 0;
}
